<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../config/left.html">
            <!-- sidebar end -->
            <!-- content start-->
            <div class="admin-content">
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><@s.m "global.position"/>:  角色管理 - <@s.m "global.edit"/></div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <form class="ropt">
                            <input type="submit" value="<@s.m "global.backToList"/>" onclick="this.form.action='list.do';" class="return-button"/>
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <@p.form id="baseForm" action="o_update.do" labelWidth="15">
                        <@p.text colspan="1" width="50" label="角色名" name="name" value=role.name required="true" class="required" maxlength="100"/>
                        <@p.text colspan="1" width="50" label="排列顺序" name="priority" value=role.priority required="true" class="required digits" maxlength="5" style="width:70px"/><@p.tr/>
                        <@p.radio colspan="2" label="拥有所有权限" name="super" value=role.super list={"true":"global.true","false":"global.false"}/><@p.tr/>
                        <@p.td colspan="2" label="功能权限"><#assign perms=role.perms/><#include "perms.html"/></@p.td><@p.tr/>
                    <@p.td colspan="2"><@p.hidden name="id" value=role.id/><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
            </@p.form>
            </div>
    </div>



    </div>

    </div>

<script type="text/javascript">
var perms = [<#list role.perms as p>"${p}"<#if p_has_next>,</#if></#list>];
function disablePerms() {
	if($("input[name=super]:checked").val()=="true") {
		$(".perm-container input[type=checkbox]").attr("disabled","disabeld");
	} else {
		$(".perm-container input[type=checkbox]").removeAttr("disabled");
	}
}
$(function() {
	disablePerms();
	$("#baseForm").validate();
	$(".perm-container input[type=checkbox]").each(function() {
		var perm = $(this).val();
		var index = perm.indexOf(",");		
		if(index!=-1) {
			perm = perm.substring(0,index);
		}
		for(var i=0,len=perms.length;i<len;i++) {
			if(perms[i]==perm) {
				$(this).attr("checked",true);
				break;
			}
		}
	});
	$("input[name=super]").bind("click",function(){
		disablePerms();
	});
});
</script>

</body>
</html>